#if 0
int* corpFlightBookings(int** bookings, int bookingsSize, int* bookingsColSize, int n, int* returnSize){
    *returnSize = n;
    int *ans = malloc(sizeof(int) * n);
    memset(ans, 0, sizeof(int) * n);
    int i, j;
    for (i = 0; i < bookingsSize; i++) {        
        for (j = bookings[i][0]; j < bookings[i][1]; j++) {
            ans[j] += bookings[i][3];
        }
    }
    return ans;
}
#endif
int* corpFlightBookings(int** bookings, int bookingsSize, int* bookingsColSize, int n, int* returnSize){
    *returnSize = n;
    int *ans = malloc(sizeof(int) * n);
    memset(ans, 0, sizeof(int) * n);
    int i, j;
    for (i = 0; i < bookingsSize; i++) {
        // 从 bookings[i][0] - 1 上车，从bookings[i][1]下车       
        ans[bookings[i][0] - 1] += bookings[i][2];
        if (bookings[i][1] < n) {
            ans[bookings[i][1]] -= bookings[i][2];
        }        
    }   
    for (i = 1; i < n; i++) {   
        ans[i] += ans[i - 1];
    }
    return ans;
}
